<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>绘制一个黄色的矩形，边框为黑色</title>
<style type="text/css">
canvas {
	border:1px solid #000;
}
</style>
<script type="text/javascript">
function DrawRect(){
	var canvas=document.getElementById("canvas");
	var context = canvas.getContext("2d");
	// 绘制矩形边框
	context.strokeStyle="#000";				//设置边框颜色
	context.lineWidth=1;						//指定边框宽度
	context.strokeRect(50,50,150,100);			//绘制矩形边框
	// 填充矩形形状
	context.fillStyle="#f90";					//设置填充颜色
	context.fillRect(50,50,150,100);				//填充矩形区域
}
window.addEventListener("load",DrawRect,true);
</script>
</head>
<body style="overflow:hidden">
<canvas id="canvas" width="400" height="300">你的浏览器不支持该功能！</canvas>
</body>
</html>
